package com.transaction.simulate.mapper;

import com.transaction.simulate.model.dto.Channel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ChannelMapper {

    @Select("SELECT * FROM t_channel t WHERE t.channelCode = #{channelCode} ")
    Channel selectChannelByChannelCode(@Param("channelCode") String channelCode);

    @Select("SELECT * FROM t_channel t WHERE t.creatorCode = #{creatorCode} and t.receiverCode = #{receiverCode}")
    Channel selectChannelByCreatorAndReceiverCode(@Param("receiverCode") String receiverCode,
                                                 @Param("creatorCode") String creatorCode);

    @Select("SELECT t.channelCode FROM t_channel t ORDER BY t.channelCode")
    List<String> selectChannelCodeList();

    @Insert("INSERT INTO t_channel ( channelCode,creatorCode, creatorName, receiverCode, receiverName, versionCode,dealFileTypes ) VALUES (#{channelCode},#{creatorCode}, #{creatorName}, #{receiverCode}, #{receiverName}, #{versionCode},#{dealFileTypes})")
    void addChannel(Channel channel);

    int deleteChannel(@Param("channelList") List<Channel> channelList);

    List<Channel> getChannel(Channel channel);

}
